<?php

//创建websocket client对象
$cli = new swoole_http_client("127.0.0.1", 9502);
$cli2 = new swoole_http_client("127.0.0.1", 9501);

$cli->on('message', function ($_cli, $frame) use ($cli2) {
    var_dump($frame->data);
    $cli2->push($frame->data);
});

$cli2->on('message', function ($_cli, $frame) {
    var_dump($frame->data);
});

$cli->upgrade('/', function ($cli) {
    echo $cli->body;
    $cli->push("hello client");
});

$cli2->upgrade('/', function ($cli) {
    echo $cli->body;
    $cli->push("hello client");
});

